<?php

namespace App\Http\Controllers\Admin;

use App\Handles\KimVpnHandler;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class AdminController extends Controller
{
    public function index()
    {
        $infos = app(KimVpnHandler::class)->info();
        $infos['vps_id'] = env('VPN_API_ID');
        $infos['planRam'] = to_size($infos['plan_ram'], 2);
        $infos['mem_available_kb'] = round(to_size($infos['mem_available_kb'],1),1);
        $infos['veDiskQuotaGb'] = $infos['ve_disk_quota_gb'];
        $infos['veUsedDiskSpaceB'] = $infos['ve_used_disk_space_b'];
        $infos['veDiskData'] = to_size($infos['ve_used_disk_space_b'], 3) . "/" . $infos['ve_disk_quota_gb'];
        $infos['veDiskDataRatio'] = round(to_size($infos['ve_used_disk_space_b'], 3) / $infos['ve_disk_quota_gb'],2) * 100;
        $infos['swapAvailableKb'] = round(to_size($infos['swap_available_kb'], 1), 0);
        $infos['planSwap'] = round(to_size($infos['plan_swap'],2),2);
        $infos['SwapData'] = $infos['planSwap']."/".$infos['swapAvailableKb'];
        $infos['SwapDataRatio'] = round($infos['planSwap'] / $infos['swapAvailableKb'],2)*100;
        $infos['planMonthlyData'] = to_size($infos['ve_used_disk_space_b'], 3) . "/" . to_size($infos['plan_monthly_data'], 3);
        $infos['monthlyDatRatio'] = round(to_size($infos['ve_used_disk_space_b'], 3) / to_size($infos['plan_monthly_data'], 3),2) * 100;
        $infos['dataNextReset'] = date('Y-m-d', $infos['data_next_reset']);
        dd($infos);
        return view('admin.index', compact('infos'));
    }
}
